      SUBROUTINE PROPM(M,RNG1,RNG2,EGVL,EGVR,CLR,CRL,R,MX,MXT2,
     1                  IOUT)
C
C     THIS SUBROUTINE COMPUTES THE COMPLEX PROPAGATOR MATRIX R
C     CORRESPONDING TO THE INTERVAL RNG1 TO RNG2.
C       
      IMPLICIT REAL*8 (A-H,O-Z)
      COMPLEX*16 EGVL(MX),EGVR(MX),CRL(MX,MX),CLR(MX,MX)
      COMPLEX*16 R(MXT2,MXT2)
      COMPLEX*16 ZERO,ONE,FK1,FK2,FAC,U,V
      COMPLEX*16 CHDH,CJDJ,CDSRT
      COMPLEX*16 WJ,WH
C
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
      ZERO=DCMPLX(0.0,0.0)
      ONE=DCMPLX(1.0,0.0)
C
C     THE LOGIC, ON RETURNING TO THE MAIN PROGRAM COUPLE DICTATES
C     WHAT PART OF THE FULL PROPAGATOR MATRIX TO BE USED TO COUPLE
C     THE MODES.
C
      IF (IOUT .EQ. 0) THEN
C
C     IOUT =  0 IS THE TWO WAY COUPLED MODE SOLUTION.
C
      DO 200 II=1,M
C
      FK2=FKB*CDSRT(ONE-EGVR(II))
      FAC=2.0D0*FK2
C
      DO 100 I=1,M
C
      FK1=FKB*CDSRT(ONE-EGVL(I))
C
      U=FK2*CRL(II,I)
      V=FK1*CLR(II,I)
C
      WJ=CJDJ(EGVL(I),RNG1,RNG2)
      WH=CHDH(EGVL(I),RNG1,RNG2)
      R(M+II,M+I)=(U+V)*WH/FAC
      R(M+II,I)=(U-V)*WJ/FAC
      R(II,M+I)=(U-V)*WH/FAC
      R(II,I)=(U+V)*WJ/FAC
C
  100 CONTINUE
  200 CONTINUE
C
      ELSE IF (IOUT .EQ. -1) THEN
C
C     IOUT = -1 GIVES AN APPROXIMATION TO THE SINGLE SCATTER
C     APPROXIMATION SEE: 'THE PROBLEM OF ENERGY CONSERVATION
C     IN ONE WAY MODELS,'BY PORTER, JENSEN AND FERLA,
C     JASA 89, PG. 1058-1067 (1991).
C
      DO 400 II=1,M
C
      FK2=FKB*CDSRT(ONE-EGVR(II))
      FAC=2.0D0*FK2
C
      DO 300 I=1,M
C
      FK1=FKB*CDSRT(ONE-EGVL(I))
C
      U=FK2*CRL(II,I)
      V=FK1*CLR(II,I)
C
      WH=CHDH(EGVL(I),RNG1,RNG2)
      R(M+II,M+I)=(U+V)*WH/FAC
C
  300 CONTINUE
  400 CONTINUE
C
C
      ELSE IF (IOUT .EQ. 1) THEN
C
C     IOUT=1 GIVES THE ONE WAY SOLUTION. THE PROPAGATOR MATRIX
C     REPRESENTS PROPAGATION FROM RNG1 TO RNG2 FOLLOWED BY THE
C     PROJECTION ON TO THE MODES ON THE RIGHT
C
      DO 600 II=1,M
      DO 500 I=1,M
C
      WH=CHDH(EGVL(I),RNG1,RNG2)
      R(M+II,M+I)=CRL(II,I)*WH
C
  500 CONTINUE
  600 CONTINUE
C
      ELSE IF(IOUT .EQ. 2) THEN
C
C     USE THE DIAGONAL PROPAGATOR OF THE ADABATIC APPROXIMATION.
C     A RATIO OF SQUARE ROOTS REPLACES THE SQUARE ROOT OF THE
C     WAVE NUMBER ON THE LEFT WITH THE SQUARE ROOT OF THE WAVE
C     NUMBER ON THE RIGHT, AS REQUIRED BY THE WKB APPROXIMATION.
C     THE DIAGONAL OF THE COUPLING MATRIX CLR IS USE TO ADJUST
C     FOR A POLARITY CHANGE IN THE MODES (R. B. EVANS, 8/3/05)
C
      DO 800 II=1,M
C
      FK2=FKB*CDSRT(ONE-EGVR(II))
C
      DO 700 I=1,M
C
      IF(II .EQ. I) THEN
      FK1=FKB*CDSRT(ONE-EGVL(I))
      WH=CHDH(EGVL(I),RNG1,RNG2)
      FAC=(FK1+FK2)/2.0D0
      R(M+I,M+I)=(FAC/FK2)*WH
C
C     ADJUST FOR POLARITY CHAGE
C
      IF(DREAL(CLR(I,I)) .LT. 0.0D0) R(M+I,M+I)=-R(M+I,M+I) 
C
C     THE ABOVE RATIO APPORXIMATES R(M+II,M+I)=CDSRT(FK1/FK2)*WH
C     WITHOUT THE BRANCH CUT DISCONTINUITIES OF THE SQUARE ROOT
C
      ELSE
      R(M+II,M+I)=ZERO
      END IF
C
  700 CONTINUE
  800 CONTINUE
C
      END IF
C
      RETURN
      END
